package com.jenings.shop.controller;

import com.jenings.shop.entity.Manager;
import com.jenings.shop.service.ManagerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = {"管理员gly"})
@RestController
@RequestMapping("/managerApi")
public class ManagerController {
    @Autowired
    ManagerService managerService;
    //查询全部管理员
    @ApiOperation(value = "查询全部管理员")
    @RequestMapping(value = "/selectAll" , method = RequestMethod.POST)
    public List<Manager> selectAll(){
        List<Manager> managerList = managerService.selectAll();
        return managerList;
    }
    //查询部分管理员
    @ApiOperation(value = "查询部分管理员")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "glyname", value = "管理员名称", required = true, dataTypeClass = String.class)
    })
    @RequestMapping(value = "/selectSome" , method = RequestMethod.POST)
    public List<Manager> selectSome(@RequestParam(value = "glyname") String glyname){
        List<Manager> managerList = managerService.seleceSome(glyname);
        return managerList;
    }
    //查询管理员个人信息
    @ApiOperation(value = "查询管理员")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "glyname", value = "管理员名称", required = true, dataTypeClass = String.class)
    })
    @RequestMapping(value = "/selectByte" , method = RequestMethod.POST)
    public Manager selectByte(@RequestParam(value = "glyname") String glyname){
        Manager manager = managerService.selectByte(glyname);
        return manager;
    }
    //修改个人信息
    @ApiOperation(value = "修改个人信息")
    @RequestMapping(value = "/updateByte" , method = RequestMethod.POST, produces = "application/json")
    public boolean updateByte(@RequestBody Manager manager){
        return managerService.updateByte(manager);
    }
    //删除管理员
    @ApiOperation(value = "删除管理员")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "glyid", value = "管理员id", required = true, dataTypeClass = String.class)
    })
    @RequestMapping(value = "/delByte" , method = RequestMethod.POST)
    public boolean delByte(@RequestParam(value = "glyid") Integer glyid){
        return managerService.delByte(glyid);
    }
    //增加管理员
    @ApiOperation(value = "添加管理员")
    @RequestMapping(value = "/addByte" , method = RequestMethod.POST, produces = "application/json")
    public boolean addByte(@RequestBody Manager manager){
        return managerService.addByte(manager);
    }
}
